import matplotlib.pyplot as plt
from scipy import signal
from scipy.io import wavfile

import sys

if len(sys.argv)<2:
   sys.exit(1)



wav_file_name = sys.argv[1]
if not wav_file_name.startswith("/"): 
    wav_file_name = "/disk1/speech_commands_v0.01/" + wav_file_name




if not wav_file_name.endswith(".wav"): 
   wav_file_name+=".wav"
   
print(wav_file_name)

sample_rate, samples = wavfile.read(wav_file_name)
frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate)

plt.pcolormesh(times, frequencies, spectrogram)
#plt.imshow(spectrogram)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()

#print(spectrogram.__dir__())

#print(sample_rate)
#print(samples)
print(frequencies)
print( times)
